# -*- coding: UTF-8 -*-

# 导入linecache模块
import linecache
import os

# 定义一个获取大文件内容的函数
def get_content(path):
    # 读取缓存中的内容，以字符串形式返回
    if(os.path.exists(path)):
        content = ''
        cache_data = linecache.getlines(path)
        for line in range(len(cache_data)):
            content += cache_data[line]
        return content
    else:
        print("The path [{}] is not exist!".format(path))

path = 'F:\\研一下\\项目\\微博医疗大数据分析\\医疗demo汇总\\数据脱敏\\data.txt'
content = get_content(path)
print(content)